package im.elephas.androfan.common.widget;

import im.elephas.androfan.R;
import im.elephas.androfan.activity.AndroFanActivity;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MoreWidget extends GeneralWidget implements OnClickListener {

	public interface MoreOpration {
		public void doMore();
	}

	public MoreOpration mMoreOpration;
	private View refreshButtonView;
	private ProgressBar refreshProgressBar;
	private ImageView refreshImageView;
	private TextView refreshButton;

	public MoreWidget(ViewGroup parentView, AndroFanActivity androFanActivity,
			MoreOpration moreOpration) {
		super(parentView, androFanActivity);
		this.mMoreOpration = moreOpration;

		refreshButtonView = getActivity().getLayoutInflater().inflate(
				R.layout.statusesbutton, null);
		super.setWidgetView(refreshButtonView);
		refreshButtonView.setClickable(false);
		refreshButtonView.setOnClickListener(this);

		refreshButton = (TextView) refreshButtonView
				.findViewById(R.id.statusesButton);
		refreshButton.setText("更多");

		refreshProgressBar = (ProgressBar) getWidgetView().findViewById(
				R.id.buttonProgressBar);
		refreshProgressBar.setVisibility(View.INVISIBLE);

		refreshImageView = (ImageView) getWidgetView().findViewById(
				R.id.buttonImageView);
		refreshImageView
				.setImageResource(android.R.drawable.ic_menu_recent_history);
		refreshProgressBar.setVisibility(View.INVISIBLE);
		refreshImageView.setVisibility(View.VISIBLE);
	}

	@Override
	public void onClick(View arg0) {
		mMoreOpration.doMore();

		refreshButtonView.setClickable(false);
		refreshProgressBar.setVisibility(View.VISIBLE);
		refreshImageView.setVisibility(View.INVISIBLE);
	}

}
